package com.graduate.examapp.view.customview

import android.content.Context
import android.util.AttributeSet
import android.view.MotionEvent
import com.google.android.material.floatingactionbutton.FloatingActionButton

class SliderFloattingActionButton : FloatingActionButton {
    constructor(context: Context, attributeSet: AttributeSet) : super(context, attributeSet)
    private var lastX = 0f
    private var lastY = 0f

    override fun onTouchEvent(event: MotionEvent): Boolean {
        when (event?.action) {
            MotionEvent.ACTION_DOWN -> {
                lastY = event.y
                lastX = event.x
            }
            MotionEvent.ACTION_MOVE -> {
                left += (event.x - lastX).toInt()
                top += (event.y - lastY).toInt()
                right += (event.x - lastX).toInt()
                bottom += (event.y - lastY).toInt()
            }
        }
        return true
    }
}